package com.koron.css2.newProjectCenter.mapper;

import com.koron.css2.newProjectCenter.bean.query.PubUpStoreQueryBean;
import com.koron.css2.newProjectCenter.vo.PubUpStoreListVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PubUpStoreMapper {

    List<PubUpStoreListVO> selecList(PubUpStoreQueryBean bean);

    Integer updateOrSave(PubUpStoreQueryBean bean);

    String selectStoreNameById(@Param("id") String id);

    Integer delete(@Param("id") String id);

    @Select("select count(0) from pj_material_store where warehouse_id = #{id} and is_delete = false")
    Integer getCountByStoreId(@Param("id") String id);

    @Select("select quantity from pj_material_store where is_delete = false and warehouse_id = #{storeId} and material_id = #{materialId}")
    Integer getQuantityByStoreIdAndMaterialId(@Param("storeId") String storeId, @Param("materialId") String materialId);

    @Select("select sum(quantity) from pj_material_store where is_delete = false and material_id = #{materialId}")
    Integer getTotalQuantityByMaterialId(@Param("materialId") String materialId);

    @Select("select stock_upper_limit from pub_up_material where is_deleted = false and id = #{materialId} ")
    Integer getUpperLimitByMaterialId(@Param("materialId") String materialId);

    @Select("select stock_lower_limit from pub_up_material where is_deleted = false and id = #{materialId} ")
    Integer getLowerLimitByMaterialId(@Param("materialId") String materialId);

    void updateQuantityByStoreIdAndMaterialId(@Param("storeId") String storeId, @Param("materialId") String materialId, @Param("materialNum") Integer materialNum, @Param("isAdd") boolean isAdd);

    @Select("select original_quantity from pj_material_store where is_delete = false and warehouse_id = #{storeId} and material_id = #{materialId}")
    Integer getOriginalQuantityByStoreIdAndMaterialId(@Param("storeId") String storeId, @Param("materialId") String materialId);

    Integer getSumDocIdList(@Param("materialId") String materialId, @Param("storeId") String storeId, @Param("isEnter") boolean isEnter);
}
